﻿using System;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.Text;

namespace xCarLinkMP3Organizer
{
    abstract class WinampCommand
    {
        public void Execute(DiscViewModel dvm)
        {
            InternalExecute(GetPsi(dvm), dvm);
        }

        protected abstract void InternalExecute(ProcessStartInfo psi, DiscViewModel dvm);

        private ProcessStartInfo GetPsi(DiscViewModel dvm)
        {
            return new ProcessStartInfo(GetWinampExecutable(), GetArgs(dvm).ToString());
        }

        protected static string GetWinampExecutable()
        {
            return ConfigurationManager.AppSettings["winamp"];
        }

        protected virtual StringBuilder GetArgs(DiscViewModel dvm)
        {
            return new StringBuilder();;
        }

        protected string GetPlaylistDir()
        {
            return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Winamp");
        }
    }
}